<html>
<head>
	<meta charset="utf-8" />
<title>教师交流共享系统</title>
<link rel="stylesheet" type="text/css" href="https://s.sydfxedu.cn/_static/v1/css/style.css"/>

<link rel="stylesheet" href="https://s.sydfxedu.cn/_static/v1/css/contentDetail.css" />

<script type="text/javascript" src="https://s.sydfxedu.cn/_static/v1/js/jquery-1.8.3.min.js" ></script>
<link rel="stylesheet" type="text/css" href="https://s.sydfxedu.cn/static/jquery-validation/1.11.0/jquery.validate.min.css"/>
<script type="text/javascript" src="https://s.sydfxedu.cn/static/jquery-validation/1.11.0/jquery.validate.min.js" ></script>
<script src="https://s.sydfxedu.cn/_static/v1/js/underscore-min.js" type="text/javascript"></script>
<script src="https://s.sydfxedu.cn/_static/v1/js/underscore.string-2.3.0.min.js" type="text/javascript"></script>
<script type="text/javascript" src="https://s.sydfxedu.cn/static/common/jeesite.js" ></script>
<style>
.controls .select_box{display:none;}
.controls a.btn{
	display:inline-block;
	border-radius: 2px;
    color: #ffffff;
    height: 32px;
    line-height: 32px;
    width: 100px;
    color: #ffffff;
    text-align: center;
    margin: 10px;
    box-sizing: border-box;
    background: #21C9C5; none repeat scroll 0 0;
}
#cke_content{margin-left:-5px;}
body {
    background: #ffffff;
}
#courseText,#ad{
	width: 49%;
	display: inline-block;
}
</style>
<script>
 var _navValue = "1";
 $(document).ready(function(){
	var isCourseware = "";
	var isAppend = "";
	if(isCourseware == 'true'){
		$("#courseCon2").show();
	}
	if(isAppend == 'true'){
		$("#fb").attr("checked",true);
		$("#ad").show();
	}
	
	 $("#inputForm").validate({
		 	ignore:[],
			submitHandler: function(form){
				loading('正在提交，请稍等...');
				form.submit();
			},
			errorElement: "span",
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			}
		});
	 $("#couseType").change(function(){
			var _n = $(this).val();
			if(_n == 2){
				$("#courseCon2").show();
			}else{
				$("#courseCon2").hide();
			}
		});
	 $("#fb").click(function(){
		 var isChecked = $(this).prop("checked");
		 if(isChecked){
			 $("#ad").show();
			}else{
			  $("#ad").hide();			
			 }
	 })
 })
 function call(){
	 window.close(); 
	// window.location.href = "/tes/f/tch/tes/courseware/tesCourseware/list";
 }
</script>
</head>
<body>
<div class="main-top">
		<ul class="tab-btn">
		<li class="top-seclect"><a href="/tes/f/tch/tes/courseware/tesCourseware/form">资源上传</a></li>
		</ul>
</div>
<div class=" con-list">
	<div class="dynamic loglist">
		<form id="inputForm" class="formg" action="/tes/f/tch/tes/courseware/tesCourseware/save" method="post">
			<input id="id" name="id" type="hidden" value=""/>
			<ul>
				<li>
					<label for="">类型<span>*</span></label>
					<div class="select_box select-drop">
                    	<div class=" showing">
               			<select id="couseType" name="type" class="input-xlarge ">
							<option value="" selected="selected"></option>
							<option value="1">微课</option><option value="2">教学设计</option><option value="3">课件</option><option value="4">论文</option><option value="5">图片</option>
						</select>
                     	</div>
                   	</div>
				</li>
				<li>
					<label for="">年级<span>*</span></label>
					<div class="select_box select-drop">
		            	<div class=" showing">
			       			<select id="grade" name="grade" class="input-xlarge ">
								<option value="" selected="selected"></option>
								<option value="1">一年级</option><option value="2">二年级</option><option value="3">三年级</option><option value="4">四年级</option><option value="5">五年级</option><option value="6">六年级</option>
							</select>
		             	</div>
		           	</div>
				</li>
				<li><label for="">学科<span>*</span></label>
				<input id="subject" name="subject" placeholder="请填写学科" class="input-xlarge required" type="text" value="" maxlength="64"/>
				</li>
				<li><label for="">资源名称<span>*</span></label>
				<input id="title" name="title" placeholder="请填写资源名称" class="input-xlarge required" type="text" value="" maxlength="30"/>
				</li>
				<div id="courseText" >
					<li><label for="">教学内容：<span>*</span></label>
						<div class="control-group input-append" style="display:inline-block;">
							<textarea id="content" name="content" class="input-xlarge required" rows="4" cols="30">
</textarea>
<script type="text/javascript">include('ckeditor_lib','https://s.sydfxedu.cn/_static/v1/plugins/ckeditor/',['ckeditor.js']);</script>
<script type="text/javascript">
	var contentCkeditor = CKEDITOR.replace("content");
	contentCkeditor.config.width = "600px";
	contentCkeditor.config.height = "200px";
	contentCkeditor.config.ckfinderPath="/tes/static/ckfinder";
	var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
	contentCkeditor.config.ckfinderUploadPath="/"+year+"/"+month+"/";//
	CKEDITOR.on('instanceReady', function () {
	    $.each(CKEDITOR.instances, function (instance) {
	        CKEDITOR.instances[instance].document.on("keyup", CK_jQ);
	        CKEDITOR.instances[instance].document.on("paste", CK_jQ);
	        CKEDITOR.instances[instance].document.on("keypress", CK_jQ);
	        CKEDITOR.instances[instance].document.on("blur", CK_jQ);
	        CKEDITOR.instances[instance].document.on("change", CK_jQ);
	    });
	});
	function CK_jQ() {
	    for (instance in CKEDITOR.instances) {
	        CKEDITOR.instances[instance].updateElement();
	    }
	}//
</script>
						</div>
					</li>
					<li><label for="">上传附件</label>
					<div class="control-group">
		                <label class="control-label"></label>
		                <div class="controls" style="display:inline-block !important">
			                <input id="attachmentUrl" name="attachmentUrl" maxlength="255" class="input-xlarge" type="hidden" value=""/>
<ol id="attachmentUrlPreview"></ol><a href="javascript:" onclick="attachmentUrlFinderOpen();" class="btn">选择</a>&nbsp;<a href="javascript:" onclick="attachmentUrlDelAll();" class="btn">清除</a>
<script type="text/javascript">
	function attachmentUrlDbPath(path){
		if(!path) return path;
		var USERFILES_BASE_PATH = "/userfiles/";		
		return USERFILES_BASE_PATH + _.string.strRight(path, USERFILES_BASE_PATH);
	}
	function attachmentUrlViewPath(path){
		if(!path) return path;
		return "/tes" + attachmentUrlDbPath(path);
	}
	function attachmentUrlFinderOpen(){//
		var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
		var url = "/tes/static/ckfinder/ckfinder.html?type=files&start=files:/"+year+"/"+month+
			"/&action=js&func=attachmentUrlSelectAction&thumbFunc=attachmentUrlThumbSelectAction&cb=attachmentUrlCallback&dts=0&sm=0";
		windowOpen(url,"文件管理",1000,700);
		//top.$.jBox("iframe:"+url+"&pwMf=1", {title: "文件管理", width: 1000, height: 500, buttons:{'关闭': true}});
	}
	function attachmentUrlSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		for(var i=0; i<files.length; i++){//
			url += attachmentUrlDbPath(files[i].getUrl());//
			if (i<files.length-1) url+="|";
		}//
		$("#attachmentUrl").val(url);//
		attachmentUrlPreview();
		//top.$.jBox.close();
	}
	function attachmentUrlThumbSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		console.info("files.length:"+files.length);
		for(var i=0; i<files.length; i++){
			url += attachmentUrlDbPath(files[i].getThumbnailUrl());
			if (i<files.length-1) url+="|";
		}//
		$("#attachmentUrl").val(url);//
		attachmentUrlPreview();
		//top.$.jBox.close();
	}
	function attachmentUrlCallback(api){
		ckfinderAPI = api;
	}
	function attachmentUrlDel(obj){
		var url = attachmentUrlDbPath($(obj).prev().attr("url"));
		$("#attachmentUrl").val($("#attachmentUrl").val().replace("|"+url,"","").replace(url+"|","","").replace(url,"",""));
		attachmentUrlPreview();
	}
	function attachmentUrlDelAll(){
		$("#attachmentUrl").val("");
		attachmentUrlPreview();
	}
	function attachmentUrlPreview(){
		var li, urls = $("#attachmentUrl").val().split("|");
		$("#attachmentUrlPreview").children().remove();
		console.info("urls.length:"+urls.length);
		var url = "";
		if($("#attachmentUrl").val()){
			for (var i=0; i<urls.length; i++){			
				url += attachmentUrlDbPath(urls[i]);
				if (i<urls.length-1) url+="|";
				urls[i] = attachmentUrlViewPath(urls[i]);
			}//
			$("#attachmentUrl").val(url);//
		}
		
		for (var i=0; i<urls.length; i++){
			if (urls[i]!=""){//
				li = "<li><a href=\""+urls[i]+"\" url=\""+urls[i]+"\" target=\"_blank\">"+decodeURIComponent(urls[i].substring(urls[i].lastIndexOf("/")+1))+"</a>";//
				li += "&nbsp;&nbsp;<a href=\"javascript:\" onclick=\"attachmentUrlDel(this);\">×</a></li>";
				$("#attachmentUrlPreview").append(li);
			}
		}
		if ($("#attachmentUrlPreview").text() == ""){
			$("#attachmentUrlPreview").html("<li style='list-style:none;padding-top:5px;'>无</li>");
		}
	}
	attachmentUrlPreview();
</script>
		                </div>
	                </div>
	             </li>
				</div>
				<div id="ad" hidden>
					
	             	<div id="" >
					<li><label for="">复备内容：</label>
						<div class="control-group input-append" style="display:inline-block;">
							<textarea id="appendContent" name="appendContent" class="input-xlarge" rows="4" cols="30">
</textarea>
<script type="text/javascript">include('ckeditor_lib','https://s.sydfxedu.cn/_static/v1/plugins/ckeditor/',['ckeditor.js']);</script>
<script type="text/javascript">
	var appendContentCkeditor = CKEDITOR.replace("appendContent");
	appendContentCkeditor.config.width = "600px";
	appendContentCkeditor.config.height = "200px";
	appendContentCkeditor.config.ckfinderPath="/tes/static/ckfinder";
	var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
	appendContentCkeditor.config.ckfinderUploadPath="/"+year+"/"+month+"/";//
	CKEDITOR.on('instanceReady', function () {
	    $.each(CKEDITOR.instances, function (instance) {
	        CKEDITOR.instances[instance].document.on("keyup", CK_jQ);
	        CKEDITOR.instances[instance].document.on("paste", CK_jQ);
	        CKEDITOR.instances[instance].document.on("keypress", CK_jQ);
	        CKEDITOR.instances[instance].document.on("blur", CK_jQ);
	        CKEDITOR.instances[instance].document.on("change", CK_jQ);
	    });
	});
	function CK_jQ() {
	    for (instance in CKEDITOR.instances) {
	        CKEDITOR.instances[instance].updateElement();
	    }
	}//
</script>
						</div>
					</li>
					</div>
					<li><label for="">上传复备附件</label>
					<div class="control-group">
		                <label class="control-label"></label>
		                <div class="controls" style="display:inline-block !important">
			                <input id="appendUrl" name="appendUrl" maxlength="1024" class="input-xlarge" type="hidden" value=""/>
			                <ol id="appendUrlPreview"></ol><a href="javascript:" onclick="appendUrlFinderOpen();" class="btn">选择</a>&nbsp;<a href="javascript:" onclick="appendUrlDelAll();" class="btn">清除</a>
<script type="text/javascript">
	function appendUrlDbPath(path){
		if(!path) return path;
		var USERFILES_BASE_PATH = "/userfiles/";		
		return USERFILES_BASE_PATH + _.string.strRight(path, USERFILES_BASE_PATH);
	}
	function appendUrlViewPath(path){
		if(!path) return path;
		return "/tes" + appendUrlDbPath(path);
	}
	function appendUrlFinderOpen(){//
		var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
		var url = "/tes/static/ckfinder/ckfinder.html?type=files&start=files:/"+year+"/"+month+
			"/&action=js&func=appendUrlSelectAction&thumbFunc=appendUrlThumbSelectAction&cb=appendUrlCallback&dts=0&sm=0";
		windowOpen(url,"文件管理",1000,700);
		//top.$.jBox("iframe:"+url+"&pwMf=1", {title: "文件管理", width: 1000, height: 500, buttons:{'关闭': true}});
	}
	function appendUrlSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		for(var i=0; i<files.length; i++){//
			url += appendUrlDbPath(files[i].getUrl());//
			if (i<files.length-1) url+="|";
		}//
		$("#appendUrl").val(url);//
		appendUrlPreview();
		//top.$.jBox.close();
	}
	function appendUrlThumbSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		console.info("files.length:"+files.length);
		for(var i=0; i<files.length; i++){
			url += appendUrlDbPath(files[i].getThumbnailUrl());
			if (i<files.length-1) url+="|";
		}//
		$("#appendUrl").val(url);//
		appendUrlPreview();
		//top.$.jBox.close();
	}
	function appendUrlCallback(api){
		ckfinderAPI = api;
	}
	function appendUrlDel(obj){
		var url = appendUrlDbPath($(obj).prev().attr("url"));
		$("#appendUrl").val($("#appendUrl").val().replace("|"+url,"","").replace(url+"|","","").replace(url,"",""));
		appendUrlPreview();
	}
	function appendUrlDelAll(){
		$("#appendUrl").val("");
		appendUrlPreview();
	}
	function appendUrlPreview(){
		var li, urls = $("#appendUrl").val().split("|");
		$("#appendUrlPreview").children().remove();
		console.info("urls.length:"+urls.length);
		var url = "";
		if($("#appendUrl").val()){
			for (var i=0; i<urls.length; i++){			
				url += appendUrlDbPath(urls[i]);
				if (i<urls.length-1) url+="|";
				urls[i] = appendUrlViewPath(urls[i]);
			}//
			$("#appendUrl").val(url);//
		}
		
		for (var i=0; i<urls.length; i++){
			if (urls[i]!=""){//
				li = "<li><a href=\""+urls[i]+"\" url=\""+urls[i]+"\" target=\"_blank\">"+decodeURIComponent(urls[i].substring(urls[i].lastIndexOf("/")+1))+"</a>";//
				li += "&nbsp;&nbsp;<a href=\"javascript:\" onclick=\"appendUrlDel(this);\">×</a></li>";
				$("#appendUrlPreview").append(li);
			}
		}
		if ($("#appendUrlPreview").text() == ""){
			$("#appendUrlPreview").html("<li style='list-style:none;padding-top:5px;'>无</li>");
		}
	}
	appendUrlPreview();
</script>
		                </div>
	                </div>
	             	</li>
				</div>
				<div id="courseCon2" class="hidden" >
					<li><label for="">上传课件</label>
						<div class="control-group" >
			                <label class="control-label"></label>
			                <div class="controls" style="display:inline-block !important">
				                <input id="coursewareUrl" name="coursewareUrl" maxlength="255" class="input-xlarge" type="hidden" value=""/>
<ol id="coursewareUrlPreview"></ol><a href="javascript:" onclick="coursewareUrlFinderOpen();" class="btn">选择</a>&nbsp;<a href="javascript:" onclick="coursewareUrlDelAll();" class="btn">清除</a>
<script type="text/javascript">
	function coursewareUrlDbPath(path){
		if(!path) return path;
		var USERFILES_BASE_PATH = "/userfiles/";		
		return USERFILES_BASE_PATH + _.string.strRight(path, USERFILES_BASE_PATH);
	}
	function coursewareUrlViewPath(path){
		if(!path) return path;
		return "/tes" + coursewareUrlDbPath(path);
	}
	function coursewareUrlFinderOpen(){//
		var date = new Date(), year = date.getFullYear(), month = (date.getMonth()+1)>9?date.getMonth()+1:"0"+(date.getMonth()+1);
		var url = "/tes/static/ckfinder/ckfinder.html?type=files&start=files:/"+year+"/"+month+
			"/&action=js&func=coursewareUrlSelectAction&thumbFunc=coursewareUrlThumbSelectAction&cb=coursewareUrlCallback&dts=0&sm=0";
		windowOpen(url,"文件管理",1000,700);
		//top.$.jBox("iframe:"+url+"&pwMf=1", {title: "文件管理", width: 1000, height: 500, buttons:{'关闭': true}});
	}
	function coursewareUrlSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		for(var i=0; i<files.length; i++){//
			url += coursewareUrlDbPath(files[i].getUrl());//
			if (i<files.length-1) url+="|";
		}//
		$("#coursewareUrl").val(url);//
		coursewareUrlPreview();
		//top.$.jBox.close();
	}
	function coursewareUrlThumbSelectAction(fileUrl, data, allFiles){
		var url="", files=ckfinderAPI.getSelectedFiles();
		console.info("files.length:"+files.length);
		for(var i=0; i<files.length; i++){
			url += coursewareUrlDbPath(files[i].getThumbnailUrl());
			if (i<files.length-1) url+="|";
		}//
		$("#coursewareUrl").val(url);//
		coursewareUrlPreview();
		//top.$.jBox.close();
	}
	function coursewareUrlCallback(api){
		ckfinderAPI = api;
	}
	function coursewareUrlDel(obj){
		var url = coursewareUrlDbPath($(obj).prev().attr("url"));
		$("#coursewareUrl").val($("#coursewareUrl").val().replace("|"+url,"","").replace(url+"|","","").replace(url,"",""));
		coursewareUrlPreview();
	}
	function coursewareUrlDelAll(){
		$("#coursewareUrl").val("");
		coursewareUrlPreview();
	}
	function coursewareUrlPreview(){
		var li, urls = $("#coursewareUrl").val().split("|");
		$("#coursewareUrlPreview").children().remove();
		console.info("urls.length:"+urls.length);
		var url = "";
		if($("#coursewareUrl").val()){
			for (var i=0; i<urls.length; i++){			
				url += coursewareUrlDbPath(urls[i]);
				if (i<urls.length-1) url+="|";
				urls[i] = coursewareUrlViewPath(urls[i]);
			}//
			$("#coursewareUrl").val(url);//
		}
		
		for (var i=0; i<urls.length; i++){
			if (urls[i]!=""){//
				li = "<li><a href=\""+urls[i]+"\" url=\""+urls[i]+"\" target=\"_blank\">"+decodeURIComponent(urls[i].substring(urls[i].lastIndexOf("/")+1))+"</a>";//
				li += "&nbsp;&nbsp;<a href=\"javascript:\" onclick=\"coursewareUrlDel(this);\">×</a></li>";
				$("#coursewareUrlPreview").append(li);
			}
		}
		if ($("#coursewareUrlPreview").text() == ""){
			$("#coursewareUrlPreview").html("<li style='list-style:none;padding-top:5px;'>无</li>");
		}
	}
	coursewareUrlPreview();
</script>
			                </div>
		                </div>
	                </li>
                </div>
				<li><label for="">是否添加复备 </label> <input id="fb" type="checkbox" style="width: auto;"></li>
				<li><label for=""></label>
				<button class="btn btn-striped">保存</button> 
				<button id="btnCancel" class="btn btn-cancel" onclick="call();return false;">取消</button>
				</li>
			</ul>
		</form>
	</div>
</div>
</body>
</html>